<form method="post" id="frmAngkatan" action="<?= base_url() ?>angkatan/popupadd">
    <div class="modal-body">
        <div class="span5">
            <div class="row">
                <div class="span2">Tahun</div>
                <input type="text" name="txtYear" class="span1" id="txtYear" value="<?= @$angkatan->year +1 ?>" readonly="readonly"/>
                <font class="strerr"><?= @$err->year ?></font>
            </div>
            <div class="row">
                <div class="span2">Nama</div>
                <input type="text" name="txtAngkatan" class="span3" id="txtAngkatan" value="Angkatan <?= @$angkatan->year + 1 - 1991 ?>" readonly="readonly"/>
                <font class="strerr"><?= @$err->officename ?></font>
            </div>
            <div class="row">
                <div class="span2">Alias</div>
                <input type="text" name="txtName" class="span3" id="txtName" value="<?= @$alumni->name ?>"/>
                <font class="strerr"><?= @$err->name ?></font>
            </div>
        </div>
    </div>
    <div style="clear: both;"></div>
    <div class="modal-footer">
        <input type="submit" class="btn btn-primary" value="Simpan"/>
        <a href="#" class="btn btn-inverse" onclick="batal()">Batal</a>
    </div>
</form>
<script>
    function batal(){
        $('#free').modal('hide');
    }
    $(".modal").css({
        'width' : '500',
        'margin-top':($(window).height()-$(".modal").height())/2, 
        'top':'0',
        'margin-left':($(window).width()-500)/2, 
        'left' : '0'
    }) ;
    $("#frmAngkatan").submit(function(event) {
        event.preventDefault();
        var $form = $( this ),
        url = $form.attr( 'action' );
        console.log($form.serialize());
        $.post(url, $form.serialize(),
        function(data){
            if(data.code == 1 ){
                //$('#free').modal('hide');
                var path = $(location).attr("href");
                window.location = path;
            }else{
                alert(data.err);
            }
        }, "json");
    });
                
</script>